package com.ruoyi.wareManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wareManagement.domain.MigrationQuery;
import com.ruoyi.wareManagement.service.IMigrationQueryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 移库查询Controller
 * 
 * @author admin
 * @date 2024-07-01
 */
@RestController
@RequestMapping("/wareManagement/migrationQuery")
public class MigrationQueryController extends BaseController
{
    @Autowired
    private IMigrationQueryService migrationQueryService;

    /**
     * 查询移库查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:migrationQuery:list')")
    @GetMapping("/list")
    public TableDataInfo list(MigrationQuery migrationQuery)
    {
        startPage();
        List<MigrationQuery> list = migrationQueryService.selectMigrationQueryList(migrationQuery);
        return getDataTable(list);
    }

    /**
     * 导出移库查询列表
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:migrationQuery:export')")
    @Log(title = "移库查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MigrationQuery migrationQuery)
    {
        List<MigrationQuery> list = migrationQueryService.selectMigrationQueryList(migrationQuery);
        ExcelUtil<MigrationQuery> util = new ExcelUtil<MigrationQuery>(MigrationQuery.class);
        util.exportExcel(response, list, "移库查询数据");
    }

    /**
     * 获取移库查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:migrationQuery:query')")
    @GetMapping(value = "/{migrationId}")
    public AjaxResult getInfo(@PathVariable("migrationId") Long migrationId)
    {
        return success(migrationQueryService.selectMigrationQueryByMigrationId(migrationId));
    }

    /**
     * 新增移库查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:migrationQuery:add')")
    @Log(title = "移库查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MigrationQuery migrationQuery)
    {
        return toAjax(migrationQueryService.insertMigrationQuery(migrationQuery));
    }

    /**
     * 修改移库查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:migrationQuery:edit')")
    @Log(title = "移库查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MigrationQuery migrationQuery)
    {
        return toAjax(migrationQueryService.updateMigrationQuery(migrationQuery));
    }

    /**
     * 删除移库查询
     */
    @PreAuthorize("@ss.hasPermi('wareManagement:migrationQuery:remove')")
    @Log(title = "移库查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{migrationIds}")
    public AjaxResult remove(@PathVariable Long[] migrationIds)
    {
        return toAjax(migrationQueryService.deleteMigrationQueryByMigrationIds(migrationIds));
    }
}
